const host = "https://api.poshir.top/";

const request = (url, options) => {
  return new Promise((resolve, reject) => {
    wx.request({
      url: `${host}${url}`,
      method: options.method,
      data: options.data,
      header: {
        'Content-Type': 'application/json; charset=UTF-8',
      },
      success(request) {
        resolve(request.data)
      },
      fail(error) {
        reject(error)
      }
    })
  })
}


const get = (url, options = {}) => {
  return request(url, { method: 'GET', data: options })
}

const post = (url, options) => {
  return request(url, { method: 'POST', data: options })
}

export default {
  get,post
}